const axios = require('axios');
const appid = 'wxce0e6da6bfb0e3bf';
const secret = '6ea142ea17b0b32f7a189e758f77365a';

function main() {
  const url = `https://api.weixin.qq.com/cgi-bin/token?appid=${appid}&secret=${secret}&grant_type=client_credential`;
  return new Promise((resolve, reject) => {
    axios.get(url).then(res => {
      if(res.data.access_token) resolve(res.data);
      else reject(res.data);
    }).catch(err => {
      reject(err);
    })
  })
}

module.exports = main;